<script type="text/javascript">
	function deleteProjects(){  
		var count = jQuery('input.ckbChild:checked').length;
		if (count == 0){
			jQuery('#dialogDeleteProject').html('<spring:message code="message.delete.empty.project"/>');
			jQuery('#dialogDeleteProject').dialog({
		       	 modal:true,
		       	 resizable: false,
		         height:130,
	          	 width:400,	
		       	 title:'<spring:message code="message"/>',
		       	 buttons:{
		       	 	'<spring:message code="button.cancel"/>' : function() {jQuery("#dialogDeleteProject").dialog("close");}
		       	 }	
		 	});
	    }else{
		        jQuery('#dialogDeleteProject').html('<spring:message code="message.confirm.delete.project"/>');	        
		    	jQuery('#dialogDeleteProject').dialog({
			       	 modal:true,
			       	 resizable: false,
			       	 height: 130,
			       	 width:400,	
			       	 title:'<spring:message code="message"/>',			         
			         buttons: {
			        	 '<spring:message code="button.ok"/>' : function() {
			        		    jQuery('input[name=cmd]').val('deleteProjects');
			           			submitForm('frmProjects'); 				 
			           	},
			           	'<spring:message code="button.cancel"/>' : function() {
				            jQuery('#dialogDeleteProject').dialog("close");
				            jQuery('input[type="checkbox"]:checked').each(function(){
				    			this.checked = false;
				    	  	});					  	       
				         }
			          }
			     });
		}	
	}  

	function imageValidate(image){
		var img =document.getElementById(image).value;
		if(img!=''){
			var checkimg = img.toLowerCase();
			if (!checkimg.match(/(\.jpg|\.png|\.JPG|\.PNG|\.jpeg|\.JPEG)$/)){
			document.getElementById(image).focus();
			$("#"+image+"").text('<spring:message code="warning.image.invalid.format"/>');
			return false;
			}
		}
		return true;
	}

	function pagingSubmit() {
		var searchKey = jQuery("input[name=searchKey]").val();
		var statusId = jQuery("select[name=statusId]").val();
		var currentPageNum = jQuery("#paging").find(".page-selector select").val();
		var pageSize = jQuery("#paging").find("#itemsPerPage select").val();
		window.location.href = "${bean.pagingUrl}?key=" + searchKey
				+ "&status=" + statusId + "&currentPageNum=" + currentPageNum
				+ "&pageSize=" + pageSize;
	}

	jQuery(document).ready(function() {
		jQuery("input[name='startdate']").datepicker(pickerOpts);
		jQuery("input[name='enddate']").datepicker(pickerOpts);

		if (jQuery("input[name='name']").val() == 'null') {
			jQuery("input[name='name']").val('');
		}
						
		jQuery("#searchProjects").click(function() {
			jQuery('input[name=cmd]').val('searchProjects');
			submitForm('frmProjects');
		});
		
		jQuery("input[name='type']").each(function() {
            if (this.value == 'copy' && this.checked == true) {                
                jQuery("#copyProject").css("display", "block");                                
            }else{
              jQuery("#copyProject").css("display", "none");
            } 
        });
		
		jQuery("input[name='type']").click(function() {
            if (this.value == 'copy') {                
                jQuery("#copyProject").css("display", "block");                                
            }else{
              jQuery("#copyProject").css("display", "none");
            } 
        });
	});
</script>